# 使用Python 3.13作为基础镜像
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/python:3.13.0

WORKDIR /app

ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PYTHONPATH=/app \
    PIP_DEFAULT_TIMEOUT=100 \
    PIP_INDEX_URL=https://mirrors.huaweicloud.com/repository/pypi/simple \
    PIP_TRUSTED_HOST=mirrors.huaweicloud.com \
    UV_SYSTEM=1 \
    UV_INDEX_URL=https://mirrors.huaweicloud.com/repository/pypi/simple

# 安装系统依赖
RUN sed -i 's/deb.debian.org/mirrors.huaweicloud.com/g' /etc/apt/sources.list.d/debian.sources && \
    apt-get update && \
    apt-get install -y --no-install-recommends gcc git && \
    rm -rf /var/lib/apt/lists/*

# 设置工作目录
WORKDIR /app

# 安装uv
RUN pip install --upgrade pip && \
    pip install uv

# 复制依赖文件并安装依赖
COPY class-schedule-service/pyproject.toml ./

RUN pip install --upgrade pip && \
    pip install uv && \
    uv pip install --system -r pyproject.toml

# 复制项目代码
COPY class-schedule-service/ .

# 暴露端口
EXPOSE 8000

# 启动命令 - 按照 START.md 中的方式运行
CMD ["uv", "run", "uvicorn", "app.main:app", "--reload", "--host", "0.0.0.0", "--port", "8000"]